# 【练习】阶乘
# 编写一个Python程序，使用递归算法，计算给定正整数n的阶乘。阶乘的定义是从1到n所有正整数的乘积。例如3的阶乘为123=6。

def factorial_recursion(num):
    if num == 1:
        return num
    else:
        return num * factorial_recursion(num-1)

def factorial_for(num):
    sum = 1
    for i in range(1,num+1):
        sum *= i
    return sum

if __name__ == "__main__":
    print(f"4!={factorial_for(4)}")
    print(f"5!={factorial_recursion(5)}")

